public class Solution848 {
    public String shiftingLetters(String s, int[] shifts) {
        for (int i=shifts.length-2;i>=0;i--){
            shifts[i]=(shifts[i]+shifts[i+1])%26;
        }
        StringBuilder stringBuilder=new StringBuilder();
        for (int i=0;i<s.length();i++){
            stringBuilder.append((char)((s.charAt(i)+shifts[i]-'a')%26+'a'));
        }
        return stringBuilder.toString();
    }

    public static void main(String[] args) {
        System.out.println(new Solution848().shiftingLetters("abc",new int[]{3,5,9}));
    }
}
